
    //$("a[name='collect']").prev().val()



    $(function () {
        $(".des_share .d_care a").live("click",function () {
            var id = $(".j_nums .productid").val();
            if(localStorage.length == 0){
                if(confirm("请先登录")){
                    window.location.href = "Login.html";
                }
            }else if(localStorage.length>0){
                var userName = localStorage.getItem("user");
                $.ajax({
                    url : "easybuy/product/collect",
                    dataType : "json",
                    data : {"id" : id,"userName":userName},
                    type : "get",
                    success : function (data) {
                        if(data.result =="success"){
                            alert("收藏成功");
                        }else if(data.exist=="exist"){
                            alert("您已收藏过该商品！");
                        }
                    },
                    error : function (XMLHttpRequest, textStatus, errorThrown) {
                        alert("出现错误");
                        console.log(XMLHttpRequest.status);
                        console.log(XMLHttpRequest.readyState);
                        console.log(textStatus);
                    }
                });

            }

        });
    });

